package com.lxc.service.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    // 小说更新 Topic
    public static final String NOVEL_UPDATED_QUEUE = "novel.updated.queue";
    public static final String NOVEL_EXCHANGE = "novel.exchange";

    @Bean
    public DirectExchange novelExchange() {
        return new DirectExchange(NOVEL_EXCHANGE);
    }

    @Bean
    public Queue novelUpdatedQueue() {
        return new Queue(NOVEL_UPDATED_QUEUE);
    }

    @Bean
    public Binding bindingNovelUpdated(DirectExchange novelExchange, Queue novelUpdatedQueue) {
        return BindingBuilder.bind(novelUpdatedQueue).to(novelExchange).with("novel.update");
    }
}
